﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for ShopOnline
/// </summary>
public class ShopOnlineBase : BasePage
{
    public ShopOnlineBase()
    {
        this.Theme = "ShopOnline";
        //
        // TODO: Add constructor logic here
        //
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        if (Page.Title == null || Page.Title == "Untitled Page")
        {
            Page.Title = ConfigManager.SiteSubject;
        }

        CompressCss();
    }


    protected virtual void CompressCss()
    {
        int count = Page.Header.Controls.Count - 1;
        for (int i = count; i >= 0; i--)
        {
            HtmlControl c = Page.Header.Controls[i] as HtmlControl;
            if (c != null && c.Attributes["type"] != null &&
                c.Attributes["type"].Equals("text/css", StringComparison.OrdinalIgnoreCase))
            {
                Page.Header.Controls.Remove(c);
            }
        }
        string link = "    <link href=\"../App_Themes/" + Page.Theme +
            "/{0}\" type=\"text/css\" rel=\"stylesheet\" />\r\n";
        Literal lit = new Literal();
        lit.Text = string.Format(link, "share.css") +
            string.Format(link, "shopOnline.css") +
            string.Format(link, "shopOnlineGridView.css");
        Page.Header.Controls.Add(lit);
    }
}
